<template>
  <el-popconfirm :title="text" :width="200" @confirm="() => (disabled ? null : $emit('confirm'))">
    <template #reference>
      <span :class="[className, { 'disabled': disabled }]">
        <slot></slot>
      </span>
    </template>
  </el-popconfirm>
</template>

<script lang="ts" setup>
import { ElPopconfirm } from "element-plus";
interface props {
  text?: string;
  disabled?: boolean;
  class?: string;
}
defineEmits(["confirm"]);
const { text = "是否删除当前数据", disabled = false, class: className = "" } = defineProps<props>();  
</script>

<style scoped>
.disabled {
  color: var(--el-text-color-disabled);
}
</style>
